function count_same_elements(collection) {
  let obj={};
  let arr=[];
  for(let item of collection){
    if(item.length !== 1){
      if(!obj[item[0]]){
         obj[item[0]] = {} ;
         obj[item[0]].name =item[0] ;
         obj[item[0]].summary = parseInt(item[2]) ; 
      }else if(item.length==5){
       obj[item[0]].summary += parseInt(item.slice(2,4));
     } else{
        obj[item[0]].summary += parseInt(item[2]);
      }
 
    }else{
     if(!obj[item]){
       obj[item]={};
       obj[item].name=item;
      obj[item].summary=1;
     }else{
      obj[item].summary++
     }
    }
  }
  for(let name in obj){
    arr.push(obj[name]);
  }
  return arr; //在这里写入代码
}

module.exports = count_same_elements;
